package com.runvp.rest.misc;

import com.runvp.common.annotation.Log;
import com.runvp.common.core.controller.BaseController;
import com.runvp.common.core.domain.AjaxResult;
import com.runvp.common.enums.BusinessType;
import com.runvp.service.biz.service.IDictService;
import com.runvp.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 消费者Controller
 *
 * @author runvp
 * @date 2022-09-15
 */
@Controller
@ResponseBody
@RequestMapping("/app/config")
public class ConfigController extends BaseController {

    @Autowired
    private ISysConfigService sysConfigService;
    @Autowired
    private IDictService dictService;
    /**
     * 查询配置
     */
    @Log(title = "查询配置", businessType = BusinessType.OTHER)
    @GetMapping("/get")
    public AjaxResult getData(String key) {
        return AjaxResult.success("获取成功",sysConfigService.selectConfigByKey(key));
    }
    /**
     * 系统配置
     */
    @Log(title = "系统配置", businessType = BusinessType.OTHER)
    @GetMapping("/{key}")
    public AjaxResult config(@PathVariable("key") String key) {
        return AjaxResult.success(dictService.commonConfig(key));
    }
}
